package cn.bs.busuo.content.dao.persist.repository.impl;

import cn.bs.busuo.content.dao.persist.mapper.SightArticleDetailMapper;
import cn.bs.busuo.content.dao.persist.mapper.SightArticleMapper;
import cn.bs.busuo.content.dao.persist.repository.SightArticleRepository;
import cn.bs.busuo.content.pojo.entity.ContentSightArticle;
import cn.bs.busuo.content.pojo.entity.ContentSightArticleDetail;
import cn.bs.busuo.content.pojo.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: Feng
 * @since: 2023/12/6
 */
@Repository
public class SightArticleRepositoryImpl implements SightArticleRepository {
    @Autowired
    private SightArticleMapper sightArticleMapper;

    @Autowired
    private SightArticleDetailMapper sightArticleDetailMapper;

    //判断文章标题是否存在
    @Override
    public int contentSightArticleByTitle(String title) {
        return sightArticleMapper.contentSightArticleByTitle(title);
    }

    //添加文章
    @Override
    public int addNewSightArticle(ContentSightArticle contentSightArticle) {
        return sightArticleMapper.insert(contentSightArticle);
    }

    //根据酒店文章标题查询Id
    @Override
    public Long selectSightArticleByTitle(String title) {
        return sightArticleMapper.selectSightArticleByTitle(title);
    }

    //添加文章到详情
    @Override
    public int addNewSightArticleDetail(ContentSightArticleDetail contentSightArticleDetail) {
        return sightArticleDetailMapper.insert(contentSightArticleDetail);
    }

    //搜索文章
    @Override
    public ContentSightArticle contentSightArticleById(Long id) {
        return sightArticleMapper.selectById(id);
    }

    @Override
    public int selectSightArticleById(Long id) {
        return sightArticleMapper.selectSightArticleById(id);
    }

    //删除文章
    @Override
    public int deleteSightArticle(List<Long> ids) {
        return sightArticleMapper.updateIsDisplay(ids);
    }


    //设置为推荐文章
    @Override
    public int updateIsRecommend(List<Long> ids, Integer isRecommend) {
        return sightArticleMapper.updateIsRecommend(ids,isRecommend);
    }

    //设置为不推荐文章
    @Override
    public int updateIsNotRecommend(List<Long> ids, Integer isRecommend) {
        return sightArticleMapper.updateIsNotRecommend(ids,isRecommend);
    }

    //审核通过文章
    @Override
    public int updateCheckState(List<Long> ids, Integer checkState) {
        return sightArticleMapper.updateCheckState(ids,checkState);
    }

    //审核不通过文章
    @Override
    public int updateCheckNotState(List<Long> ids, Integer checkState) {
        return sightArticleMapper.updateCheckNotState(ids,checkState);
    }

    //设置文章排序
    @Override
    public int updateSort(Long id, Integer sort) {
        return sightArticleMapper.updateSort(id,sort);
    }

    //查看排序文章
    @Override
    public List<ContentSightArticleListBySortVO> selectListBySort() {
        return sightArticleMapper.selectListBySort();
    }

    //查看未审核文章
    @Override
    public List<ContentSightArticle> selectListByCheckState() {
        return sightArticleMapper.selectListByCheckState();
    }



}
